package com.magic.gre.ui.dialog;

import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.view.View;

import com.magic.gre.R;
import com.magic.gre.adapter.YearAdapter;
import com.magic.gre.base.dialog.BaseBottomDialog;
import com.magic.gre.widget.wheel.WheelView;

import java.util.ArrayList;
import java.util.List;

/**
 * Author: Lmoumou
 * Date: 2019-01-21 17:04
 * 文件名: BirthDialog
 * 描述:
 */
public class BirthDialog extends BaseBottomDialog {

    private WheelView<Integer> wvYear;
    private WheelView<Integer> wvMonth;
    private WheelView<Integer> wvDay;

    private List<Integer> yearDataList = new ArrayList<>();
    private List<Integer> monthDataList = new ArrayList<>();
    private List<Integer> dayDataList = new ArrayList<>();

    @Override
    protected int setViewId() {
        return R.layout.dialog_birth;
    }

    @Override
    protected void initView(View view) {
        wvYear = view.findViewById(R.id.wv_year);
        wvMonth = view.findViewById(R.id.wv_month);
        wvDay = view.findViewById(R.id.wv_day);

        initYear();

        initWheelView(wvYear);
        initWheelView(wvMonth);
        initWheelView(wvDay);
    }


    @Override
    protected void initBundle(Bundle bundle) {

    }

    /**
     * 初始化年数据
     */
    private void initYear() {
        for (int i = 1900; i <= 2100; i++) {
            yearDataList.add(i);
        }

        wvYear.setWheelAdapter(new YearAdapter(mContext));
        wvYear.setWheelData(yearDataList);

        wvYear.setSelection(2);
    }

    private void initWheelView(WheelView<Integer> wheelView) {
        wheelView.setSkin(WheelView.Skin.Holo);
        wheelView.setWheelSize(5);
        WheelView.WheelViewStyle style = new WheelView.WheelViewStyle();
        style.selectedTextSize = 15;
        style.textSize = 15;
        style.backgroundColor = ContextCompat.getColor(mContext, R.color.window_bg);
        style.holoBorderColor = ContextCompat.getColor(mContext, R.color.color_DDDDDD);
        style.textColor = ContextCompat.getColor(mContext, R.color.color_999999);
        style.selectedTextColor = ContextCompat.getColor(mContext, R.color.main_color);
        wheelView.setStyle(style);
    }
}
